Repository navigation
Pitfall: GCC 6.5 tests the wrong byte with btst on a value in memory - #57
Merged
Merged
Conversation
*tst_bftst_mem/_mem1/_mem2 used bit number 7 - POS on the operand's first byte, giving e.g. btst #-23,(a3) for bit 1 of a long. Found in ApolloOS R10; fixed by ApolloCrossDev PR #26. Workaround for older installs: -mno-bitfield. Includes a kb:compile check (kb:expect-not btst #-). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New pitfall
toolchain/pitfalls/gcc-btst-memory-bit-number.md(statusdraft, originai-assisted, owner WDrijver).What it covers
ApolloCrossDev's GCC 6.5 compiles a one-bit test on an
int/shortin memory (if (info[i] & 2),if (*req & MEMF_CLEAR)) asbtstwith a bit number below 0 on the operand's first byte, e.g.btst #-23,(a3)instead ofbtst #1,(3,a3).btston memory uses only the low three bits of the number, so the wrong byte is tested. The cause is in*tst_bftst_mem,*tst_bftst_mem1and*tst_bftst_mem2(m68k.md); it is not the bbb pass.-mno-bitfield.-Soutput for bit operations on memory with a bit number outside 0..7 (not the object files: data in code gives false alarms).Checks
check_frontmatter.py,check_links.py,check_saga_addresses.py,check_owners.py: OK locally.kb:compileblock haskb:expect-not btst #-. It needs the CI toolchain built with tools/schema.json: the frontmatter rules in one file #26: the CI cache key coversGCC-6.50-Dev-Linux.shandCompilers/_archives, which tools/schema.json: the frontmatter rules in one file #26 changed, so CI rebuilds it.Knowledge base files relied on
toolchain/compiler-variants.md(which variant applies which patches)toolchain/pitfalls/gcc-bbb-shift-wrong-code.mdandgcc-bbb-autoinc.md(format, and to rule out the bbb pass)Evidence
Measured and source-level: compiler output with and without the patch; ApolloOS R10 (7662 C files) compiled both ways (4 sites, otherwise identical assembly); Regina REXX on a V4 (Core 12856) before and after.
🤖 Generated with Claude Code